package controllers;

import java.util.List;


import models.User;




	public class Security extends Secure.Security {
	    
	    static boolean authenticate(String username, String password) {
	        User user = User.find("byEmail", username).first();
	        return user != null && user.pwdHash.equals(password);
	    }  
	    static boolean isConnected() {
            return session.contains("username");
        }

	    static String connected() {
            return session.get("username");
        }
	    public static User getConnected()
		{
			String usr = (isConnected() ? connected() : "").toLowerCase();
			
			
			List<User> teams=User.findAll();
			for(User team:teams){
		
				if(team.email.toLowerCase().equals(usr)){
					return team;
				}
				}
			return null;
			}

	    
	}

